import { EnumSchema } from '@/utils/common/types';
import { PresetColorEnum } from '@/enums/colorEnum';

//#region 申请单状态
export enum StatusEnum {
  WaitApply = 0,
  RdApprove,
  IpnApprove,
  CompleteApply,
}

export class StatusEntity {
  Type: StatusEnum;
  /** 显示描述 */
  Display: string;
  /** 颜色 */
  Color?: PresetColorEnum | string;

  constructor(status: StatusEnum, color?: PresetColorEnum | string) {
    this.Type = status;
    this.Color = color;
    switch (status) {
      case StatusEnum.WaitApply:
        this.Display = '待申请';
        this.Color = this.Color ? this.Color : PresetColorEnum.Green;
        break;
      case StatusEnum.RdApprove:
        this.Display = '研发审批';
        this.Color = this.Color ? this.Color : PresetColorEnum.Blue;
        break;
      case StatusEnum.IpnApprove:
        this.Display = 'IPN审批';
        this.Color = this.Color ? this.Color : PresetColorEnum.Blue;
        break;
      case StatusEnum.CompleteApply:
        this.Display = '申请完成';
        this.Color = this.Color ? this.Color : PresetColorEnum.Cyan;
        break;
    }
  }
}

export function getStatusSchema(enableTag = true): EnumSchema[] {
  const enumSchema: EnumSchema[] = [];
  const typeEntities: StatusEntity[] = [
    new StatusEntity(StatusEnum.WaitApply),
    new StatusEntity(StatusEnum.RdApprove),
    new StatusEntity(StatusEnum.IpnApprove),
    new StatusEntity(StatusEnum.CompleteApply),
  ];
  typeEntities.forEach((item) => {
    enumSchema.push({
      key: item.Type as number,
      label: item.Display,
      value: item.Type as number,
      tag: enableTag,
      tagColor: item.Color,
    });
  });
  return enumSchema;
}
//#endregion
